{include file="public/header" /}
<link href="/public/static/admin/myeditor/themes/default/default.css" rel="stylesheet" type="text/css" />
<script charset="utf-8" src="/public/static/admin/myeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/public/static/admin/myeditor/lang/zh_CN.js"></script>

<script>
    KindEditor.ready(function(K) {
        var editor = K.editor({
            allowFileManager : true
        });
    {for start="1" end="3"}
        K('#img{$i}_btn').click(function() {
            editor.loadPlugin('image', function() {
                editor.plugin.imageDialog({
                    imageUrl : K('#img{$i}').val(),
                    clickFn : function(url, title, width, height, border, align) {
                        K('#img{$i}').val(url);
                        editor.hideDialog();
                    }
                });
            });
        });
    {/for}

    });
</script>


<div class="layui-layout layui-layout-admin">
	{include file="public/left" /}

	<div class="layui-body">
		<div class="layui-tab layui-tab-brief" lay-filter="tab">
			<ul class="layui-tab-title">
				<li><a href="{:url('Sort/Index')}">栏目列表</a></li>
				<li class="layui-this"><a href="{:url('Sort/Add')}">栏目添加</a></li>
			</ul>
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<form action="" method="post" class="layui-form" onSubmit="return check_manager_add(this);">
						<input type="hidden" name="id" value="{$v['id']}">
						{if condition="session('admin_id') eq 99999999"}
							<div class="layui-form-item">
								<label class="layui-form-label">所属栏目</label>
								<div class="layui-input-inline">
									<select name="pid" lay-filter="model" lay-verify="required" >
										<option value="0">无(属一级栏目)</option>
										{volist name="sort" id="s"}
											<option value="{$s.id}" {if condition="$s['id'] eq $v['pid']"} selected{/if}>{:str_repeat("&nbsp;&nbsp;└",$s['level'])}{$s.catname}</option>
										{/volist}
									</select>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">栏目模块</label>
								<div class="layui-input-inline">
									<select name="model_id" lay-filter="model" required lay-verify="required" >
										<option value="">请选择</option>
										{volist name=":get_mytable_list('model')" id="s"}
											<option value="{$s.id}|{:get_model_zd($s['id'],'model_c')}|{:get_model_zd($s['id'],'model_a')}" {if condition="$s['id'] eq $v['model_id']"} selected{/if}>{$s.model_name}</option>
										{/volist}
									</select>
								</div>
							</div>

						{else/}


							<input type="hidden" name="pid" value="{$v.pid}">
							<if condition="!$v['pid']">
								<input type="hidden" name="model_id" value="{:get_sort_zd($v['pid'],'model_id')}">
								<else />
								<input type="hidden" name="model_id" value="{$v.model_id}">
							</if>
							<div class="layui-form-item">
								<label class="layui-form-label">所属栏目</label>
								<div class="layui-input-inline">
									{:get_sort_zd($v['pid'])}
								</div>
							</div>
						{/if}



						<div class="layui-form-item">
							<label class="layui-form-label">栏目名称</label>
							<div class="layui-input-inline">
								<input type="text" name="catname" value="{$v['catname']}" lay-verify="required" placeholder="请输入栏目名称" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">英文名称</label>
							<div class="layui-input-inline">
								<input type="text" name="encatname" value="{$v['encatname']}" placeholder="请输入英文名称" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">页面标题</label>
							<div class="layui-input-inline">
								<input type="text" name="seotitle" value="{$v['seotitle']}" placeholder="请输入页面标题" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">页面关键字</label>
							<div class="layui-input-inline">
								<textarea name="seokeywords"  style="width:520px;height:100px;" class="layui-textarea">{$v['seokeywords']}</textarea>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">页面描述</label>
							<div class="layui-input-inline">
								<textarea name="seodescription"  style="width:520px;height:100px;" class="layui-textarea">{$v['seodescription']}</textarea>
							</div>
						</div>


						



						{if condition="session('admin_id') eq 99999999"}
							<div class="layui-form-item">
								<label class="layui-form-label">所属模板</label>
								<div class="layui-input-inline">
									<input type="text" name="templet" id="templet" value="{$v['templet']}" required lay-verify="required" placeholder="请输入所属模板" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">控制器</label>
								<div class="layui-input-inline">
									<input type="text" name="sort_c" id="sort_c" value="{$v['sort_c']}" required lay-verify="required" placeholder="请输入控制器" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">操作方法</label>
								<div class="layui-input-inline">
									<input type="text" name="sort_a" id="sort_a" value="{$v['sort_a']}" required lay-verify="required" placeholder="请输入操作方法" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
				                <label class="layui-form-label">图片类型</label>
				                <div class="layui-input-inline" id="imgtype">
				                    <select name="imgtype" class="imgtype">
				                        <option value="0" {if condition="$v.imgtype eq 0"}selected {/if}>普通</option>
				                        <option value="1" {if condition="$v.imgtype eq 1"}selected {/if}>自由裁剪</option>
				                        <option value="2" {if condition="$v.imgtype eq 2"}selected {/if}>水印</option>
				                    </select>
				                </div>
				            </div>


				            <div class="layui-form-item waterimgtype" {if condition="$v.imgtype neq 2"} style="display: none" {/if}>
				                <label class="layui-form-label">水印类型</label>
				                <div class="layui-input-inline" id="waterimgtype">
				                    <select name="waterimgtype">
				                        <option value="0" {if condition="$v.waterimgtype eq 0"}selected {/if}>全站</option>
				                        <option value="1" {if condition="$v.waterimgtype eq 1"}selected {/if}>当前栏目</option>
				                    </select>
				                </div>
				            </div>

							<div class="layui-form-item">
								<label class="layui-form-label">图片数量</label>
								<div class="layui-input-inline">
									<input type="text" name="imgnum" value="{$v['imgnum']}" placeholder="请输入图片数量" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">图片尺寸</label>
								<div class="layui-input-inline">
									<input type="text" name="imgsize" value="{$v['imgsize']}" placeholder="请输入图片尺寸 多个用,分割" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">图片名称</label>
								<div class="layui-input-inline">
									<input type="text" name="imgname" value="{$v['imgname']}" placeholder="请输入图片名称 多个用,分割" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">多图尺寸</label>
								<div class="layui-input-inline">
									<input type="text" name="titleimgsize" value="{$v['titleimgsize']}" placeholder="请输入多图上传尺寸" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">内部自定义</label>
								<div class="layui-input-inline">
									<input type="text" name="sort_url" id="sort_url" value="{$v['sort_url']}" placeholder="请输入内部自定义链接" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">外部跳链接</label>
								<div class="layui-input-inline">
									<input type="text" name="outlinkurl" value="{$v['outlinkurl']}" placeholder="请输入外部跳链接" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">前台文件名</label>
								<div class="layui-input-inline">
									<input type="text" name="inlinkurl" value="{$v['inlinkurl']}" placeholder="请输入前台文件名" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">子栏目权限</label>
								<div class="layui-input-block">
									<input type="radio" name="isopen" value="1" title="开放"  {:get_my_checked($v['isopen'],1)}>
									<input type="radio" name="isopen" value="0" title="关闭"  {:get_my_checked($v['isopen'],0)}>
								</div>
							</div>
						{else/}
							<input type="hidden" name="templet" value="{$v['templet']}">
				            <input type="hidden" name="sort_c" value="{$v['sort_c']}">
				            <input type="hidden" name="sort_a" value="{$v['sort_a']}">
				            <input type="hidden" name="imgtype" value="{$v['imgtype']}">
				            <input type="hidden" name="imgnum" value="{$v['imgnum']}">
				            <input type="hidden" name="titleimgsize" value="{$v['titleimgsize']}">
				            <input type="hidden" name="imgsize" value="{$v['imgsize']}">
				            <input type="hidden" name="imgname" value="{$v['imgname']}">
				            <input type="hidden" name="model_id" value="{$v['model_id']}">
				            <input type="hidden" name="outlinkurl" value="{$v['outlinkurl']}">
				            <input type="hidden" name="inlinkurl" value="{$v['inlinkurl']}">
				            <input type="hidden" name="isopen" value="{$v['isopen']}">
				            <input type="hidden" name="imgtype" value="{$v['imgtype']}">
				            <input type="hidden" name="waterimgtype" value="{$v['waterimgtype']}">
				            <input type="hidden" name="waterimg" value="{$v['waterimg']}">
				            <input type="hidden" name="waterlocation" value="{$v['waterlocation']}">
						{/if}



						{for start="1" end="3"}
							<?php $zd="img$i";?>
							<div class="layui-form-item">
								<label class="layui-form-label">{:get_banner_imgname($i)}</label>
								<div class="layui-input-inline">
									<input type="text" name="img{$i}" id="img{$i}" value="{$v['img'.$i]}" placeholder="请上传配置图片"  class="layui-input">
								</div>
								<button type="button" id="img{$i}_btn" class="layui-btn" data-des="ico">
									<i class="layui-icon">&#xe67c;</i>上传图片
								</button>
								<font color="red">图片大小:{:get_cfg_var("post_max_size")}内,图片尺寸：{:get_banner_imgsize($i)}px</font>
							</div>
						{/for}

							<div class="layui-form-item waterimg" {if condition=" $v['imgtype'] eq 2 and $v['waterimgtype'] eq 1 "} style="display: block"{else /}style="display: none" {/if}>
				                <label class="layui-form-label">水印图片</label>
				                <div class="layui-input-inline">
				                    <input type="text" name="waterimg" id="waterimg" value="{$v['waterimg']}" placeholder="请上传水印图片" class="layui-input">
				                </div>
				                <button type="button" id="waterimg_btn" class="layui-btn" data-des="ico">
				                    <i class="layui-icon"></i>上传水印图片
				                </button>
				            </div>


				            <div class="layui-form-item waterlocation" {if condition=" $v['imgtype'] eq 2 "} style="display: block"{else /}style="display: none" {/if}>
				                <label class="layui-form-label">水印位置</label>
				                <div class="layui-input-inline" id="waterlocation">
				                    <select name="waterlocation">
				                        <option value="1" {if condition="$v.waterlocation eq 1"}selected {/if}>上左</option>
				                        <option value="2" {if condition="$v.waterlocation eq 2"}selected {/if}>上中</option>
				                        <option value="3" {if condition="$v.waterlocation eq 3"}selected {/if}>上右</option>
				                        <option value="4" {if condition="$v.waterlocation eq 4"}selected {/if}>中左</option>
				                        <option value="5" {if condition="$v.waterlocation eq 5"}selected {/if}>中中</option>
				                        <option value="6" {if condition="$v.waterlocation eq 6"}selected {/if}>中右</option>
				                        <option value="7" {if condition="$v.waterlocation eq 7"}selected {/if}>下左</option>
				                        <option value="8" {if condition="$v.waterlocation eq 8"}selected {/if}>下中</option>
				                        <option value="9" {if condition="$v.waterlocation eq 9"}selected {/if}>下右</option>
				                    </select>
				                </div>
				            </div>

						<div class="layui-form-item">
							<label class="layui-form-label">栏目排序</label>
							<div class="layui-input-inline" style="width: 120px;">
								<input type="text" name="disorder" value="{$v['disorder']}" placeholder="请输入栏目排序" class="layui-input" style="width: 120px;">
							</div>
							数字越小越在前
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">状态</label>
							<div class="layui-input-block">
								<input type="radio" name="status" value="1" title="启用"  {:get_my_checked($v['status'],1)}>
								<input type="radio" name="status" value="0" title="禁用"  {:get_my_checked($v['status'],0)}>
							</div>
						</div>

						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit >立即提交</button>
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
							</div>
						</div>

					</form>
				</div>
			</div>
		</div>
	</div>

	{include file="public/footer" /}

</div>
<script>
    layui.use('form', function(){
        var form = layui.form;
        form.on('select(model)', function(data){
            var v=data.value;
            strs=v.split("|");
            var module_id=$("#module_id").find("option:selected").attr("title");
            if(module_id>0){
                $(".show").show();
            }else{
                $(".show").hide();
            }
            $("#templet").val(strs[1]);
            $("#sort_c").val(strs[1]);
            $("#sort_a").val(strs[2]);
        });
    });
	window.onload=function() {
	    $("#imgtype .layui-anim-upbit dd").click(function () {
	        var text = $(this).attr("lay-value");
	        if(text==2){
	            $(".waterimgtype").css('display','block');
	        }else{
	            $(".waterimgtype").css('display','none');
	            $(".waterimg").css('display','none');
	            $(".waterlocation").css('display','none');
	        }

	    })

	    $("#waterimgtype .layui-anim-upbit dd").click(function () {
	        var text = $(this).attr("lay-value");
	        if(text==1){
	            $(".waterimg").css('display','block');
	            // $(".waterlocation").css('display','block');
	        }else{
	            $(".waterimg").css('display','none');
	            // $(".waterlocation").css('display','none');
	        }

	    })
	}   
</script>
</body>
</html>
